var friendHelper = require("helper/friend");
var openHelper = require("helper/open");
var nf = sm("do_Notification");
var page = sm("do_Page");
var root = ui("$");

root.setMapping({
	"imgLogo.tag" : "bussId",//好友申请applyId
	"imgLogo.source" : "logo",
	"lableName.tag" : "userId",
	"lableName.text" : "name",
	"lableTime.text" : "time",
	"labelMessage.text" : "last"
});

//同意加为好友
ui("btnAccept").on("touch", function(data, e) {
	var friendApplyId = ui("imgLogo").tag;
	friendHelper.acceptFriendApply(friendApplyId,function(data){
		page.fire("message_reflash_friend", friendApplyId);
		nf.toast("添加好友成功");
	});
});

//忽略好友申请
ui("btnIgnore").on("touch", function(data, e) {
	var friendApplyId = ui("imgLogo").tag;
	friendHelper.ignoreFriendApply(friendApplyId,function(data){
		page.fire("message_reflash_friend", friendApplyId);
		nf.toast("已忽略");
	});
})

ui("alayoutLogo").on("touch", function(data, e) {
	var userId = ui("lableName").tag;//用户ID
	if(userId != null && userId !=""){
		openHelper.openPersonal(userId);
	}
})